package com.xian.java.batch;

import com.xian.scala.batch.Person;
import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.common.functions.RichFilterFunction;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;

/**
 * java 版 flink 批处理
 */
public class JavaFlinkBatchTest {
    public static void main(String[] args) {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

        Person p = new Person(1, "jemson", new Date());
        System.out.println(p);
        String myPattern="yyyy-MM-dd HH:mm:ss"; //修改为自己想要的格式  yyyy-MM-dd HH:mm:ss SSS
        System.out.println(LocalDateTime.parse(p.birthday().toString(), DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss z yyyy", Locale.US)).format(DateTimeFormatter.ofPattern(myPattern)));

        DataSource<Person> ds = env.fromElements(p);
        ds.filter(new FilterFunction<Person>() {
            @Override
            public boolean filter(Person value) throws Exception {
                return false;
            }
        });



    }
}
